/**
 * 
 */
package reco.db.validation;

import reco.db.Constraint;
import reco.db.Domain;
import reco.db.Field;

/**
 * Constraint used to ensure that a value is not null.
 */
public class NotNullConstraint<T> extends Constraint<T> {

    /**
     * Constructs an instance of he constraint over a {@link Domain}'s {@link Field}.
     * 
     * @param constraintField
     *            field where the constraint will be applied.
     * @throws NullPointerException
     *             if constraintField is <code>null</code>.
     */
    public NotNullConstraint() {
        super("notNull", "#isNull");
    }

    /**
     * Verify thata value is not <code>null</code>.
     * 
     * @param value
     *            value to be validated.
     * @return <code>value != null</code>;
     */
    @Override
    public boolean validate(T value) {
        return value != null;
    }

    @Override
    public Object[] getErrorArguments() {
        return null;
    }

}
